#获取涨停价，以及比较得到是否涨停
def getZtPriceStr(pre_price,zt_ratio):
    ztprice = pre_price * (1.0 + zt_ratio)
    ztprice_str = '{:.2f}'.format(ztprice)
    return ztprice_str

def getPriceStr(price):
    return '{:.2f}'.format(price)
    
def getDtPriceStr(pre_price,dt_ratio):
    dtprice = pre_price * (1.0 - dt_ratio)
    dtprice_str = '{:.2f}'.format(dtprice)
    return dtprice_str

def isZT(code:str,pre_price:float,price:float):
    if code[:2] == '00' or code[:2] == '60':
        zt_ratio = 0.1
    elif code[:2] == '30' or code[:2] == '68':
        zt_ratio = 0.2
    else:
        return False
    
    if getZtPriceStr(pre_price,zt_ratio) == getPriceStr(price):
        return True
    else:
        return False
def isDT(code:str,pre_price:float,price:float):
    if code[:2] == '00' or code[:2] == '60':
        dt_ratio = 0.1
    elif code[:2] == '30' or code[:2] == '68':
        dt_ratio = 0.2
    else:
        return False
    
    if getDtPriceStr(pre_price,dt_ratio) == getPriceStr(price):
        return True
    else:
        return False